package fpt.store.main;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import fpt.store.tab.MapFPT;
import fpt.store.tab.StoreFPT;

public class StoreMain extends TabActivity implements OnTabChangeListener {

	TabHost tabHost;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.store_main);
		tabHost = getTabHost();
		tabHost.setOnTabChangedListener(this);

		TabHost.TabSpec spec;
		Intent intent;

		intent = new Intent().setClass(this, StoreFPT.class);
		spec = tabHost.newTabSpec("First").setIndicator("Cửa hàng").setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, MapFPT.class);
		spec = tabHost.newTabSpec("Second").setIndicator("Bản đồ").setContent(intent);
		tabHost.addTab(spec);

		tabHost.getTabWidget().getChildAt(1)
				.setBackgroundResource(R.drawable.map);
		tabHost.getTabWidget().setCurrentTab(0);
		tabHost.getTabWidget().getChildAt(0)
				.setBackgroundResource(R.drawable.store);
	}

	@Override
	public void onTabChanged(String tabId) {
		for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
			if (i == 0) {
//				tabHost.getTabWidget().getChildAt(i)
//						.setBackgroundResource(R.drawable.store);
			} else if (i == 1) {
//				tabHost.getTabWidget().getChildAt(i)
//						.setBackgroundResource(R.drawable.map);
			}
		}
		Log.i("tabs", "Current tab: " + tabHost.getCurrentTab());
//		if (tabHost.getCurrentTab() == 0) {
//			tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab())
//					.setBackgroundResource(R.drawable.store_over);
//		} else if (tabHost.getCurrentTab() == 1) {
//			tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab())
//					.setBackgroundResource(R.drawable.map_over);
//		}
	}

}
